<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <title>Document</title>
</head>

<body>
    <div id="root">
        <h2 v-text="n"></h2>
        <h2>当前n:{{n}}</h2>
        <button @click="add">点我n+1</button>
        <button @click="bye">点我销毁vm</button>
    </div>
    <script>
        const vm = new Vue({
            el: "#root",
            data: {
                n: 1
            },
            methods: {
                add() {
                    console.log('add');
                    this.n++
                },
                bye(){
                    console.log('bye');
                    this.$destroy()
                }
            },
            watch:{

            },
            beforeCreate() {
                console.log(this);
                // 调试 到此暂停
                // debugger;
            },
            created() {
                console.log("created");
            },
            // 未经编译的dom
            beforeMount() {
                console.log("beforeMount");
            },
            //经过编译的dom
            mounted() {
                console.log("mounted");
            },
            beforeUpdate() {
                console.log("beforeUpate");
                console.log(this.n);
            },
            updated() {
                console.log("updated");
                console.log(this.n);
                // debugger
            },
            
            
        })
    </script>
</body>

</html>